package com.ztc.controller;

import com.ztc.mapper.UserMapper;
import com.ztc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/user2")
public class AdduserController extends HttpServlet {
    @Autowired
    UserService userService;
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);

    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        String uname = request.getParameter("username");
        boolean  b3 = userService.getusername2(uname);
        System.out.println(b3);
        if(b3){
            response.getWriter().write("1");
        }else{
            response.getWriter().write("0");
        }

    }
}
